package com.zs.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class ApiController {
    /*
    * 自己实现servlet或者集成httpServlet service | doXxx 只能获取两个参数 HttpServeletRequest  HttpServletResponse
    * 不分先后顺序
    *  继续和我们讲过的注解混合使用
    * */

//    @GetMapping("/show")
//    public String show(HttpServletRequest  request, HttpServletResponse  response)
//    {
//    return "hello world";
//    }
//
//    @GetMapping("/show")
//    public String show(HttpServletResponse  response, HttpServletRequest  request)
//    {
//        return "hello world";
//    }
//    @GetMapping("/show")
//    public String show(HttpServletRequest  request)
//    {
//        return "hello world";
//    }
//    @GetMapping("/show")
//    public String show(HttpServletResponse  response)
//    {
//        return "hello world";
//    }

    @GetMapping("/show")
    public String show(@RequestParam String account, HttpSession  session){
        session.setAttribute("account",account);
        return "hello world";
    }
}
